<?php
if(cmd("morse")){
  include("controls/morseConvert.php");
  $newphrase=strtolower($msg_params);
  $morseMode="morse->text";
  for($i=0;$i<strlen($newphrase);$i++){
    if($newphrase[$i]!="." and $newphrase[$i]!="-" and $newphrase[$i]!=" "){
      $morseMode="text->morse";
      echo "\n\ntext->morse\n\n";
    }
  }
  if($morseMode=="text->morse"){
    foreach($morseconvert as $letter => $morse){
      $newphrase = str_replace($letter, $morseconvert[$letter]." ", $newphrase);
    }
    msg($newphrase);
    $morsefull="";
    $morsefull1="";
    $newphrase="";
  } else {
    $npA=explode(" ",$newphrase);
    $newphrase="";
    foreach($npA as $np){
      /*foreach($unmorseconvert as $morse => $letter){
        $np = str_replace($morse, $unmorseconvert[$morse], $np);
      }*/
      $np=$unmorseconvert[$np];
      $newphrase.=$np." ";
    }
    msg($newphrase);
    $morsefull="";
    $morsefull1="";
    $newphrase="";
  }
}
?>